import Vue from "vue"
import VueRouter from "vue-router"

/*import Msite from "../pages/Msite/Msite"
import Search from "../pages/Search/Search"
import Order from "../pages/Order/Order"
import Profile from "../pages/Profile/Profile"*/
// 路由组件的懒加载
const Msite = () => import("../pages/Msite/Msite")
const Search = () => import("../pages/Search/Search")
const Order = () => import("../pages/Order/Order")
const Profile = () => import("../pages/Profile/Profile")

import Login from "../pages/Login/Login"
import Shop from "../pages/Shop/Shop"
import ShopGoods from "../pages/Shop/ShopGoods/ShopGoods"
import ShopRatings from "../pages/Shop/ShopRatings/ShopRatings"
import ShopInfo from "../pages/Shop/ShopInfo/ShopInfo"

Vue.use(VueRouter)

export default new VueRouter({
  routes: [
    {
      path: '/',
      redirect: '/msite'
    },
    {
      path: '/msite',
      component: Msite,
      meta: {
        showFooter: true
      }
    },
    {
      path: '/search',
      component: Search,
      meta: {
        showFooter: true
      }
    },
    {
      path: '/order',
      component: Order,
      meta: {
        showFooter: true
      }
    },
    {
      path: '/profile',
      component: Profile,
      meta: {
        showFooter: true
      }
    },
    {
      path: '/login',
      component: Login
    },
    {
      path: '/shop',
      component: Shop,
      children:[
        {
          path: '/shop/shopgoods',
          component: ShopGoods
        },
        {
          path: '/shop/shopratings',
          component: ShopRatings
        },
        {
          path: '/shop/shopinfo',
          component: ShopInfo
        },
        {
          path: '',
          redirect:  '/shop/shopgoods'
        }

      ]
    }
  ],
  scrollBehavior(to, from, savedPosition) {
    return {x: 0, y: 0}
  }
})
